<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册页面</title>
    <style>
        a {
            text-decoration: none;
        }

        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: rgb(235, 235, 235);
        }

        form {
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.5);
            border-radius: 8px;
            width: 400px;
            height: 320px;
            background-color: aliceblue;
            padding: 20px;
            box-sizing: border-box;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            /* 相对于现在所处位置的位移变化，x便偏移自己宽度的50%，y偏移自己高度的50% */
        }

        h2 {
            margin-bottom: 20px;
            text-align: center;
        }

        .shurukuang {
            width: 100%;
            height: 30px;
            display: block;
            margin-bottom: 40px;
            padding-left: 10px;
            box-sizing: border-box;
        }

        #button {
            width: 40%;
            height: 30px;
        }

        #submit {
            width: 40%;
            height: 30px;
        }

        .mya {
            width: 100%;
            height: 30px;
            margin-bottom: 20px;
        }

        .mya input:nth-child(1) {
            float: left;
        }

        .mya input:nth-child(2) {
            float: right;
        }
    </style>
    <script type="text/javascript">
        function validate() {
            account = document.zhuce.name.value;
            password = document.zhuce.pwd.value;
            password1 = document.zhuce.pwd1.value;
            if (account == "") {
                alert("请输入用户名!");
                document.zhuce.name.focus();
                return false;
            }
            else if (password == "") {
                alert("请输入密码!");
                document.zhuce.pwd.focus();
                return false;
            }
            else if (password1 == "") {
                alert("请输入二次密码!");
                document.zhuce.pwd1.focus();
                return false;
            }
            else if (password != password1) {
                alert("两次密码不一致！");
                document.zhuce.pwd.focus();
                return false;
            }
            alert("申请成功，请等待管理员审核！")
            document.zhuce.submit();
        }
    </script>
</head>

<body th:background="@{/img/denglu.jpg}" style="background-repeat:no-repeat;
               background-attachment:fixed;
               background-size:100% 100%; ">
<form action="/servlet.treatApply" method="get" name="zhuce">
    <h2>注册界面</h2>
    <input class="shurukuang" name="name" type="text" placeholder="请输入账号">
    <input class="shurukuang" name="pwd" type="password" placeholder="请输入密码">
    <input class="shurukuang" name="pwd1" type="password" placeholder="请再次输入密码">
    <div class="mya">
        <input id="button" type="button" value="返回"
               onclick="window.location.href = 'http://localhost:8080/denglu.html'">
        <input id="submit" type="submit" onclick="return validate()" value="立即注册" />
    </div>
</form>
</body>

</html>